<template>
    <div class="message-box">
        <div class="inner">
             <div class="header" :class="[type]">
                {{ title }}
             </div>
            <div class="content">
                {{ content }}
            </div>
            <div class="bottom">
                <button @click="close" :class=[type]>{{ btnText}}</button>
            </div>
        </div>
    </div>
</template>

<script setup>
    import { ref } from 'vue'

    const props = defineProps({
        title: {
            type: String,
            default: '默认标题'
        },
        content: {
            type: String,
            default: '默认内容'
        },
        btnText: {
            type: String,
            default:'关闭'
        },
        show: {
            type: Boolean,
            default: false
        },
        type: {
            type: String,
            default: 'info',
            validator(value) {
                return ['info', 'success', 'warning', 'error'].includes(value)
            }
        },
        close: Function
    })

</script>

<style lang="scss" scoped>
    .message-box{
        position: fixed;;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgba(0, 0, 0, 0.5);

        .inner{
            width: 400px;
            height: 300px;
            border-radius: 10px;
           
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background-color: #fff;
            overflow: hidden;

            .header{
                height: 40px;
                width: 100%;
                background-color: #eeeeee;
                border-bottom: 1px solid #dddddd;
                display: flex;
                justify-content: center;
                align-items: center;
                font-weight: 600;
            }

            .content{
                padding: 15px;
                flex: 1;
            }

            .bottom{
                height: 40px;
                border-top: 1px solid #dddddd;
                width: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                font-weight: 600;
            }
        }
    }
</style>
